package com.wutma.friend.controller.user;

import com.wutma.common.core.constants.HttpConstants;
import com.wutma.common.core.controller.BaseController;
import com.wutma.common.core.domain.R;
import com.wutma.common.core.domain.TableDataInfo;
import com.wutma.friend.domain.exam.dto.ExamQueryDTO;
import com.wutma.friend.domain.exam.dto.ExamRankDTO;
import com.wutma.friend.domain.user.dto.UserExamDTO;
import com.wutma.friend.service.user.IUserExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("user/exam")
@RestController
public class UserExamController extends BaseController {

    @Autowired
    private IUserExamService examService;

    /**
     * 用户报名竞赛
     */
    @PostMapping("/enter")
    public R<Void> enter(@RequestHeader(HttpConstants.AUTHENTICATION) String token, @RequestBody UserExamDTO userExamDTO) {
        return toR(examService.enter(token, userExamDTO.getExamId()));
    }

    /**
     * 获取竞赛列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ExamQueryDTO examQueryDTO) {
        return examService.list(examQueryDTO);
    }
}
